package com.leaves.leetcode.array.t1343_NumOfSubarrays;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.leaves.leetcode.UnitTesting;

import java.util.List;

public class T1343Main extends UnitTesting<Object[], Integer> {

    Solution solution = new Solution();

    @Override
    protected void generateTestData() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            testDataList.add(createTestData(
                    objectMapper.readValue("[[2,2,2,2,5,5,5,8], 3, 4]", new TypeReference<Object[]>() {}),
                    3
            ));
            testDataList.add(createTestData(
                    objectMapper.readValue("[[11,13,17,23,29,31,7,5,2,3], 3, 5]", new TypeReference<Object[]>() {}),
                    6
            ));
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }




    @Override
    public Integer run(Object[] inputData) {
        List<Integer> list = (List) inputData[0];
        int[] nums  = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            nums [i] = list.get(i);
        }
        int k = (int) inputData[1];
        int threshold = (int) inputData[2];

        return solution.numOfSubarrays(nums, k, threshold);
    }
}
